import {Message} from "element-ui";

const config = require('@/config');
export default function({ $axios, store }) {
  // onRequest是@nuxtjs/axios模块提供的帮助方法
  $axios.onRequest(request => {
    request.baseURL=config.VUE_APP_BASE_URL
    request.data={}
    // // 附加令牌
    if (store.state.user.token) {
      request.headers['access_token'] = '81cc48a35fce418a853e19190fb7726c'
    }
    console.log(request, "request");
    return request;
  });
  $axios.onResponse((res)=>{
    if (res.code === 401 || res.data.code == 200 || res.data.status || res.data.code == 0 || res.data.reasonCode === 200) {
      return res.data
    }else{
      return res
    }
  })
}
